

version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
			
			cd "${outdir}"
			
* ------------------------------------------------------------------------------

* Date : March 2021 [Checked Oct 2021]

* Project : Daesh FF Working Paper (The World Bank)

* This is the do file for Table 7 in the main paper

* ------------------------------------------------------------------------------
				
	

***************************************************************************
*Table 7: Robustness across subsamples
***************************************************************************

	*Different subsamples 
	
	glo sample4 ="keep if  pew_muslims_pct>50 & pew_muslims_pct!=." //majority muslim
	glo sample5 ="keep if  pew_muslims_pct<=50" //non-majority muslim
	glo sample6 ="keep if median_frac_muslim==1" //fraction of muslims less than median
	glo sample7 ="keep if median_frac_muslim==2" //fraction of muslims more than median
	glo sample8 =`"keep if countrycode!="IRN""'
	glo sample9 =`"keep if countrycode!="IRN" & countrycode!="AZN" & countrycode!="BHR" "'
	
	glo subtitle4 = `""Muslim", "Majority","'
	glo subtitle5 = `""Muslim", "Minority","'
	glo subtitle6 = `""Muslim Prop.","$<$ Median","'
	glo subtitle7 = `""Muslim Prop.","$>$ Median","'
	glo subtitle8 = `""Drop", "Iran","'
	glo subtitle9 = `""Drop", "Shia", "Countries""'

*Column 1***

	foreach n in 4 {                        

	use "${outdir}/finaldata_CE.dta", clear 
		
		data_preamble //Invoking data prep program to clean data and create variables
		
		gen temp1=1
		replace temp1=0 if nisis_educ==01
		bys ctry: egen total_temp=total(temp1)
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
					
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop log_dist_tosyria educ2 educ3, fe vce(cluster ctry)  
		xtile median_frac_muslim = pew_muslims_pct if e(sample), nq(2)
		foreach val of numlist 1 2{
		
			gen median_frac_muslim`val' = median_frac_muslim == `val' if !missing(median_dist)
		
		}
			
		${sample`n'} //Retaining relevant sample only
	
        global options7="dec(3) nocons word se lab"
		global sortlist="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop  unemp_secondary unemp_tertiary  unemp_logdistance "

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle`n'})  nonotes "'
		
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance   educ2 educ3, fe vce(cluster ctry)  
		local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000
		moulton logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance  educ2 educ3  educ2 educ3 ctrydummy*, cl(ctry) moulton  
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 noni sortvar($sortlist) drop(educ2 educ3 ctrydummy*)  replace  addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr')

	}	
	
	
*Loop to produce Columns 2-4***

	foreach n in 5 6 7 {                        
	
	use "${outdir}/finaldata_CE.dta", clear 
		
		data_preamble //Invoking data prep program to clean data and create variables
		
		gen temp1=1
		replace temp1=0 if nisis_educ==01
		bys ctry: egen total_temp=total(temp1)
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
					
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop log_dist_tosyria educ2 educ3, fe vce(cluster ctry)  
		xtile median_frac_muslim = pew_muslims_pct if e(sample), nq(2)
		foreach val of numlist 1 2{
		
			gen median_frac_muslim`val' = median_frac_muslim == `val' if !missing(median_dist)
		
		}
			
		${sample`n'} //Retaining relevant sample only
	
        global options7="dec(3) nocons word se lab"
		global sortlist="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop  unemp_secondary unemp_tertiary  unemp_logdistance "

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle`n'})  nonotes "'
		
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance   educ2 educ3, fe vce(cluster ctry)  
		local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000
		moulton logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance  educ2 educ3  educ2 educ3 ctrydummy*, cl(ctry) moulton  
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 noni sortvar($sortlist) drop(educ2 educ3 ctrydummy*)  append  addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr')

	}

*Loop to produce Columns 5 6 (dropping iran, dropping all majority shia countries)

	foreach n in 8 9 {                        
	
	use "${outdir}/finaldata_CE.dta", clear 
		
		data_preamble //Invoking data prep program to clean data and create variables
		
		gen temp1=1
		replace temp1=0 if nisis_educ==01
		bys ctry: egen total_temp=total(temp1)
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
					
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop log_dist_tosyria educ2 educ3, fe vce(cluster ctry)  
		xtile median_frac_muslim = pew_muslims_pct if e(sample), nq(2)
		foreach val of numlist 1 2{
		
			gen median_frac_muslim`val' = median_frac_muslim == `val' if !missing(median_dist)
		
		}
			
		${sample`n'} //Retaining relevant sample only
	
        global options7="dec(3) nocons word se lab"
		global sortlist="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop  unemp_secondary unemp_tertiary  unemp_logdistance "

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle`n'})  nonotes "'
		
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance   educ2 educ3, fe vce(cluster ctry)  
		local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000
		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance  educ2 educ3, fe vce(cluster ctry)  
		
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 nor2 noni sortvar($sortlist) drop(educ2 educ3 ctrydummy*)  append  addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr')

	}
	
***************************************************
	//Storing conditions for last 3 columns  
	glo subtitle1 = `""$ N_{c} >= 33$""'
	glo subtitle2 = `""$ N_{c} >= 10$""'
	glo subtitle3 = `""$ N_{c} >= 0$""'
	
	*Column 7

	use "${outdir}/finaldata_CE.dta", clear 		
		
		data_preamble //Invoking data prep program to clean data and create variables
		
		bys ctry: egen tisis=total(nisis_educ)
		drop if  tisis<33
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
		
		
        global options1 ="dec(3) nocons word se lab"
		global sortlist ="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop $resc_all unemp_secondary unemp_tertiary $resc_fe"
		global drop_resc="ctrydummy1-ctrdummy168 educ2 educ3 1b.education_level#co.ilo2_unemp_educ o.resc_corruption_index o.resc_log_pop_tot o.ilo2_unemp_educ o.hdi o.gini o.resc_political_rights o.resc_fraction_language o.resc_fraction_religion o.resc_fraction_ethnic o.resc_log_pop_muslim_pew o.log_dist_tosyria o.resc_log_gdp_pc"

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle1},,)  nonotes "'

		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 ctrydummy*, fe vce(cluster ctry)
		local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000

		moulton logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 ctrydummy*, cl(ctry) moulton 
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 noni sortvar($sortlist)   drop ( $drop_resc ctrydummy*) append  addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr') 

	*Column 8
	
	use "${outdir}/finaldata_CE.dta", clear 
		
		data_preamble //Invoking data prep program to clean data and create variables
		
		bys ctry: egen tisis=total(nisis_educ)
		drop if  tisis<10
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
		
		
        global options1 ="dec(3) nocons word se lab"
		global sortlist ="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop $resc_all unemp_secondary unemp_tertiary $resc_fe"
		global drop_resc="ctrydummy1-ctrdummy168 educ2 educ3 1b.education_level#co.ilo2_unemp_educ o.resc_corruption_index o.resc_log_pop_tot o.ilo2_unemp_educ o.hdi o.gini o.resc_political_rights o.resc_fraction_language o.resc_fraction_religion o.resc_fraction_ethnic o.resc_log_pop_muslim_pew o.log_dist_tosyria o.resc_log_gdp_pc"

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle2},,)  nonotes "'

		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance  educ2 educ3, fe vce(cluster ctry)
        local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000
		moulton logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 ctrydummy*, cl(ctry) moulton 
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ( $drop_resc ctrydummy*) append  addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr')

		
	*Column 9	
	use "${outdir}/finaldata_CE.dta", clear 
		
		data_preamble //Invoking data prep program to clean data and create variables
		
			gen temp1=1
            replace temp1=0 if nisis_educ==0
            bys ctry: egen total_temp=total(temp1)
		    drop if  total_temp<3
		
		//Altering variable labels
		la var ilo2_unemp_educ    "\textbf{Main effects} \\Unemployment rate"
		la var unemp_logdistance             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"
		
        global options1 ="dec(3) nocons word se lab"
		global sortlist ="ilo2_unemp_educ log_wage2lag3 log_wage2lag6 log_ilo2_pop $resc_all unemp_secondary unemp_tertiary $resc_fe"
		global drop_resc="ctrydummy1-ctrdummy168 educ2 educ3 1b.education_level#co.ilo2_unemp_educ o.resc_corruption_index o.resc_log_pop_tot o.ilo2_unemp_educ o.hdi o.gini o.resc_political_rights o.resc_fraction_language o.resc_fraction_religion o.resc_fraction_ethnic o.resc_log_pop_muslim_pew o.log_dist_tosyria o.resc_log_gdp_pc"

		global options2 =`"ctitle("$ log N_{ce}$",,${subtitle3},,)  nonotes "'

		xtreg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance  educ2 educ3, fe vce(cluster ctry) 
        local clust= e(N_clust)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		areg logn_educ ilo2_unemp_educ log_ilo2_pop unemp_logdistance educ2 educ3 , absorb(ctry) vce(cluster ctry)		
        local adjr =int(e(r2_a)*1000)/1000
		moulton logn_educ ilo2_unemp_educ  log_ilo2_pop unemp_logdistance  educ2 educ3  educ2 educ3 ctrydummy*, cl(ctry) moulton 
		outreg2 using table6_1.docx, tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ( $drop_resc ctrydummy*) append addtext("Mean $ N_{ce}$", `mean', Number of countries, `clust', Country FE, Y, Education Dummies, Y, Adj. R-squared, `adjr')
	
	 
	
